#define _CRT_SECURE_NO_WARNINGS 1
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#include<unordered_map>
#include<queue>
#include<stack>

using namespace std;

class Solution {
public:
    int dx[4] = { 0,0,-1,1 };
    int dy[4] = { 1,-1,0,0 };
    int n, m;
    void solve(vector<vector<char>>& board) {
        n = board.size(), m = board[0].size();
        for (int i = 0; i < n; i++)
        {
            if (board[i][0] == 'O') bfs(board, i, 0);
            if (board[i][m - 1] == 'O') bfs(board, i, m - 1);
        }

        for (int i = 0; i < m; i++)
        {
            if (board[0][i] == 'O') bfs(board, 0, i);
            if (board[n - 1][i] == 'O') bfs(board, n - 1, i);
        }

        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                if (board[i][j] == '.') board[i][j] = 'O';
                else if (board[i][j] == 'O') board[i][j] = 'X';
            }
        }
    }

    void bfs(vector<vector<char>>& board, int x, int y)
    {
        queue<pair<int, int>> qt;
        qt.push({ x,y });
        board[x][y] = '.';
        while (qt.size())
        {
            auto [a, b] = qt.front();
            qt.pop();
            for (int i = 0; i < 4; i++)
            {
                int xi = dx[i] + a;
                int yi = dy[i] + b;
                if (xi >= 0 && xi < n && yi >= 0 && yi < m && board[xi][yi] == 'O')
                {
                    qt.push({ xi,yi });
                    board[xi][yi] = '.';
                }
            }
        }
    }
};

int main() {
    return 0;
}